<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('用户列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>用户昵称：</label>
                                <input type="text" name="userNickname"/>
                            </li>
                            <li>
                                <label style="width: 120px;">用户手机号：</label>
                                <input type="text" name="userPhone"/>
                            </li>
                            <li>
                                <label>用户类型：</label>
                                <input type="text" name="isServiceuser"/>
                            </li>
                            <li>
                                <label>个人认证：</label>
                                <select name="gerenSt">
                                    <option value="">所有</option>
                                    <option value="0">未认证</option>
                                    <option value="1">审核中</option>
                                    <option value="2">已通过</option>
                                    <option value="3">未通过</option>
                                </select>
                            </li>
                            <li>
                                <label>企业认证：</label>
                                <select name="qiyeSt">
                                    <option value="">所有</option>
                                    <option value="0">未认证</option>
                                    <option value="1">审核中</option>
                                    <option value="2">已通过</option>
                                    <option value="3">未通过</option>
                                </select>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
               <!-- <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="lm:user:add">
                    <i class="fa fa-plus"></i> 添加
                </a>-->
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="lm:user:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="lm:user:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
<!--                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="lm:user:export">
                    <i class="fa fa-download"></i> 导出
                </a>-->
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('lm:user:edit')}]];
        var removeFlag = [[${@permission.hasPermi('lm:user:remove')}]];
        var prefix = ctx + "lm/user";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "用户",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'id',
                    title: '主键',
                    visible: false
                },
                {
                    field: 'userNickname',
                    title: '用户昵称',
                    formatter: function(value, row, index) {
                        return $.table.tooltip(value);
                    }
                },
                {
                    field: 'userPic',
                    title: '用户头像',
                    formatter: function(value, row, index) {
                        return $.table.imageView(value);
                    }
                },
                {
                    field: 'userPhone',
                    title: '用户手机号'
                },
                {
                    field: 'userBalance',
                    title: '账户余额'
                },
                {
                    field: 'userType',
                    title: '用户类型'
                },
                {
                    field: 'userImg',
                    title: '身份证正面',
                    formatter: function(value, row, index) {
                        var actions = [];
                        if(row.userImg != null){
                            actions.push('<a  href="javascript:void(0)" onclick="openVinPic(\'' + row.userImg + '\')">查看</a> ');
                        }
                        return actions.join('');
                    }
                },
                {
                    field: 'userImgback',
                    title: '身份证反面',
                    formatter: function(value, row, index) {
                        var actions = [];
                        if(row.userImgback != null){
                            actions.push('<a  href="javascript:void(0)" onclick="openVinPic(\'' + row.userImgback + '\')">查看</a> ');
                        }
                        return actions.join('');
                    }
                },
                {
                    field: 'userLicense',
                    title: '营业执照',
                    formatter: function(value, row, index) {
                        var actions = [];
                        if(row.userLicense != null){
                            actions.push('<a  href="javascript:void(0)" onclick="openVinPic(\'' + row.userLicense + '\')">查看</a> ');
                        }
                        return actions.join('');
                    }
                },
                    {
                        field: 'gerenSt',
                        title: '个人认证状态'
                    },
                    {
                        field: 'qiyeSt',
                        title: '企业认证状态'
                    },
                    {
                        field: 'disReason',
                        title: '拒绝原因'
                    },
                    {
                        field: 'isValidate',
                        title: '是否封号'
                    },
                {
                    field: 'packageTimes',
                    title: '剩余次数'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="viewUser(\'' + row.id + '\')"><i class="fa fa-edit"></i>查看</a> ');
                        if(row.isValidate == "否"){

                            actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="disableUser(\'' + row.id + '\')"><i class="fa fa-remove"></i>封号</a>');
                        }
                        if(row.isValidate == "是"){
                            actions.push('<a class="btn btn-warning btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="enableUser(\'' + row.id + '\')"><i class="fa fa-remove"></i>解封</a>');

                        }
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });

        function openVinPic(userLicense){
            $.modal.open("查看图片", userLicense);
        }

        function review(id) {
            debugger;
            $.ajax({
                type: "post",
                url: ctx + "lm/user/reviewUser?id="+id,
                success: function(r) {
                    $.modal.msgSuccess("审批成功");
                }
            });
            $("#bootstrap-table").bootstrapTable('refresh', {
                silent: true
            });
        }
        function reviewDis(id) {
            debugger;
            $.ajax({
                type: "post",
                url: ctx + "lm/user/reviewUserDis?id="+id,
                success: function(r) {
                    $.modal.msgSuccess("审批成功");
                }
            });
            $("#bootstrap-table").bootstrapTable('refresh', {
                silent: true
            });
        }
        function disableUser(id) {
            $.ajax({
                type: "post",
                url: ctx + "lm/user/disableUser?id="+id,
                success: function(r) {
                    $.modal.msgSuccess("封号成功");
                }
            });
            $("#bootstrap-table").bootstrapTable('refresh', {
                silent: true
            });
        }

        function enableUser(id) {
            $.ajax({
                type: "post",
                url: ctx + "lm/user/enableUser?id="+id,
                success: function(r) {
                    $.modal.msgSuccess("解封成功");
                }
            });
            $("#bootstrap-table").bootstrapTable('refresh', {
                silent: true
            });
        }

        function viewUser(id) {
            debugger;
            //$.modal.openNoBtn("查看活动",ctx+"lm/activity/view/"+id);
            var title="查看用户信息";
            var url=ctx+"lm/user/view/"+id;
            var width;
            var height;
            var callback;
            //如果是移动端，就使用自适应大小弹窗
            if ($.common.isMobile()) {
                width = 'auto';
                height = 'auto';
            }
            if ($.common.isEmpty(title)) {
                title = false;
            }
            if ($.common.isEmpty(url)) {
                url = "/404.html";
            }
            if ($.common.isEmpty(width)) {
                width = 800;
            }
            if ($.common.isEmpty(height)) {
                height = ($(window).height() - 50);
            }
            if ($.common.isEmpty(callback)) {
                callback = function(index, layero) {
                    var iframeWin = layero.find('iframe')[0];
                    iframeWin.contentWindow.submitHandler(index, layero);
                }
            }
            layer.open({
                type: 2,
                area: [width + 'px', height + 'px'],
                fix: false,
                //不固定
                maxmin: true,
                shade: 0.3,
                title: title,
                content: url,
                // 弹层外区域关闭
                shadeClose: true,
                yes: callback,
                cancel: function(index) {
                    return true;
                }
            });
        }
    </script>
</body>
</html>